#ifndef DRAWINGVIEW_H
#define DRAWINGVIEW_H

#include <QGraphicsView>
#include <QPointF>
#include <QList>

class QGraphicsScene;
class QGraphicsPathItem;
class QGraphicsTextItem;

class DrawingView : public QGraphicsView
{
    Q_OBJECT

public:
    explicit DrawingView(QWidget *parent = nullptr);

    void setPoints(const QList<QPointF> &points);
    void clear();

protected:
    void resizeEvent(QResizeEvent *event) override;
    void wheelEvent(QWheelEvent *event) override;

private:
    void setupScene();
    void drawPoints();
    void drawSegments();
    void fitToView();
    bool isLineSegment(const QPointF &p1, const QPointF &p2, const QPointF &p3) const;
    void drawArc(const QPointF &p1, const QPointF &p2, const QPointF &p3);
    QPointF calculateCircleCenter(const QPointF &p1, const QPointF &p2, const QPointF &p3) const;

    QGraphicsScene *m_scene;
    QList<QPointF> m_points;
    QList<QGraphicsPathItem*> m_segments;
    QList<QGraphicsTextItem*> m_labels;
};

#endif // DRAWINGVIEW_H
